package com.hl.toolkit.server.tycoin.account.slaveservice;

import com.tycoin.account.slaveentity.TycoinAccountRecharge;
import com.tycoin.account.slaverepository.TycoinAccountRechargeRepository;
import com.tycoin.common.bean.PageInfo;
import com.tycoin.common.entity.Page;
import com.tycoin.common.repository.AbstractRepository;
import com.tycoin.common.service.AbstractService;
import com.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

@Service
@Transactional(value = "slaveTransactionManager", readOnly = false)
public class TycoinAccountRechargeService   extends AbstractService<TycoinAccountRecharge, Long> {

	@Autowired
	private TycoinAccountRechargeRepository tycoinAccountRechargeRepository;
	
	
	@Override
	public AbstractRepository<TycoinAccountRecharge, Long> getRepository() {
 		return tycoinAccountRechargeRepository;
	}

	
	public TycoinAccountRecharge findOneBylogno(String logno) {
		return tycoinAccountRechargeRepository.findOneBylogno(logno);
	}
	
	public TycoinAccountRecharge findOneBypaymentId(String paymentId) {
		return tycoinAccountRechargeRepository.findOneBypaymentId(paymentId);
	}
	 
 
 

	public List<TycoinAccountRecharge> queryByPage(PageInfo pageInfo, Map<String, String> parMap) {
  		String userIdStr=parMap.get("userId");
  
  		String payMode=parMap.get("payMode");
  		String paymentStatus=parMap.get("paymentStatus");
  		org.springframework.data.domain.Page<TycoinAccountRecharge> pageList=null;
		
		if(StringUtil.isNotNull(payMode)&&StringUtil.isNull(paymentStatus)){
	  		  pageList = tycoinAccountRechargeRepository.queryPaymentTimeByPayMode(userIdStr, Integer.valueOf(payMode), pageInfo.getPageRequest());
		}
		else if(StringUtil.isNull(payMode)&&StringUtil.isNotNull(paymentStatus)){
	  		  pageList = tycoinAccountRechargeRepository.queryPaymentTimeByPaymentStatus(userIdStr,  Integer.valueOf(paymentStatus), pageInfo.getPageRequest());
			 
		}else if(StringUtil.isNotNull(payMode)&&StringUtil.isNotNull(paymentStatus)){
	  		  pageList = tycoinAccountRechargeRepository.queryPaymentTimeByPaymentStatusAndPayMode(userIdStr,  Integer.valueOf(paymentStatus),  Integer.valueOf(payMode),pageInfo.getPageRequest());
		}else{
	  		  pageList = tycoinAccountRechargeRepository.queryByPage(userIdStr, pageInfo.getPageRequest());
		}
 
		return pageList.getContent();
	}


 
	public TycoinAccountRecharge findTransferAccountsInfo(long countLogId, String userId) {
 		// TODO Auto-generated method stub
		return tycoinAccountRechargeRepository.findTransferAccountsInfo(countLogId,userId);
	}


	public List<TycoinAccountRecharge> findaccountPayRechargeToDate(String startDay, String endDay, String userId) {
		 
		return tycoinAccountRechargeRepository.AccountPayRechargeToDate(startDay,endDay,userId);
	}


	public List<TycoinAccountRecharge> findBingRechargeToDate(String startDay, String endDay, String userId) {
		return tycoinAccountRechargeRepository.findBingRechargeToDate(startDay,endDay,userId);
	}


	public List<TycoinAccountRecharge> findTycoinAccountRechargeByNativeSql(String startDay, String endDay, String userId) {
		return tycoinAccountRechargeRepository.TycoinAccountRechargeToNativeSql(  startDay,   endDay,   userId);
 	}
	
 	
	public List<TycoinAccountRecharge> queryPaymentTime(String paymentTime) {
		return tycoinAccountRechargeRepository.queryPaymentTime(paymentTime);
 	}
	
	public List<TycoinAccountRecharge> findByuserId(String userId) {
		return tycoinAccountRechargeRepository.findByuserId(userId);
 	}
	
	public List<TycoinAccountRecharge> getOrderInQqByUserId(String userId) {
		return tycoinAccountRechargeRepository.getOrderInQqByUserId(userId);
 	}
	
	

}
